package com.xiguaji.tiktok.task.ranking;

import com.gugee.tiktok.common.model.dal.blogger.BloggerTypeRepository;
import com.gugee.tiktok.common.model.dal.common.RegionRepository;
import com.gugee.tiktok.common.model.dal.ranking.RankingRegionRepository;
import com.gugee.tiktok.common.model.mysql.BloggerType;
import com.gugee.tiktok.common.model.mysql.Region;
import com.gugee.tiktok.common.model.ranking.RankingEnterprise;
import com.gugee.tiktok.common.model.ranking.RankingRegion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RankingRegionService {

    @Autowired
    RankingRegionRepository rankingRegionRepository;

    @Autowired
    RegionRepository regionRepository;


    public void saveAll(List<RankingRegion> rankings){
        rankingRegionRepository.bathSave(rankings);
    }

    public List<RankingRegion> getRankings(String region, int rankingType, int belong){
        return rankingRegionRepository.findByRegionAndRankingTypeAndBelongOrderByScoreDesc(region,rankingType,belong);
    }

    public List<RankingRegion> getRankings(String region, int rankingType, int firstDate, int lastDate){
        return rankingRegionRepository.findRankings(region,rankingType,firstDate,lastDate);
    }

    public List<Region> getBloggerTypes(){
        return regionRepository.findByOrderById();
    }

}
